彻底禁用win10自动更新功能及其powershell代码 |
您所在的位置:网站首页 › powershell 运行脚本后不自动关闭 › 彻底禁用win10自动更新功能及其powershell代码 |
以下禁用步骤实际上是找微软提供的方法,可以禁用也可以恢复启用,健康无危害。 目前网络上常见的禁止更新方法有两种, 1、禁用Windows Update相关服务; 2、通过组策略禁止Windows Update更新。 事实证明这两种方法已经摆脱不了win10自动更新的魔爪,而且操作比较复杂对于小白同学很不友好。 同时也不建议像网上那些文章介绍的去删除更新服务或者大量写注册表,以下亲测有效: 一,禁用windows Update的更新,参考步骤如下:1. 在windows logo右键输入:gpedit.msc打开本地组策略 2,路径:计算机配置-管理模板-Windows组件-Windows 更新 策略名称:指定internal Microsoft更新服务日志 设置 :Enabled (只需要配置错误的URL,例如“ ..”) 3,路径:计算机配置-管理模板-Windows组件-Windows 更新 策略名称:删除使用所有 Windows 更新功能的访问权限 设置: Enabled 4,路径:计算机配置-管理模板-Windows组件-Windows 更新 策略名称:配置自动更新 设置: Disable 5,路径:计算机配置-管理模板-Windows组件-Windows 更新 策略名称:不允许更新延迟策略对 Windows 更新执行扫描 设置: Enabled 6,路径:计算机配置-管理模板-系统 策略名称:指定可选组件安装和组件修复的设置 设置: Enabled 7,设置完成过后,以管理员权限打开CMD.,执行gpupdate /force 命令。 二,将上面的操作利用powershell化,代码如下:我将其写成了powershell函数, #系统自动更新禁用 Function DisableWindowsUpdate { Write-Output "start to disable windows update" Stop-Service -Name "Windows Update" #net stop wuauserv #sc config wuauserv start=disable #net stop trustedinstaller #sc config trustedinstaller start=disable #组策略1:启用指定internal Microsoft更新服务位置 If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) { New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null } Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "UseWUServer" -Type DWord -Value 1 #组策略2:禁用配置自动更新 Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoUpdate" -Type DWord -Value 1 #组策略3:删除使用所有 Windows 更新功能的访问权限 Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "SetDisableUXWUAccess" -Type DWord -Value 1 #组策略1:故意执行错误配置 If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate")) { New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Force | Out-Null } Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "WUServer" -Type String -Value "..." Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "WUStatusServer" -Type String -Value "..." #组策略4:不允许更新延迟策略对 Windows 更新执行扫描 Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "DisableDualScan" -Type DWord -Value 1 #组策略5:策略名称:指定可选组件安装和组件修复的设置 If (!(Test-Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing")) { New-Item -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing" -Force | Out-Null } Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing" -Name "RepairContentServerSource" -Type DWord -Value 2 Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing" -Name "UseWindowsUpdate" -Type DWord -Value 2 Write-Output "disable windows update successful" } #系统自动更新禁用的反向操作 Function EnableWindowsUpdate { Write-Output "start to enable windows update" Start-Service -Name "Windows Update" #组策略1:禁用指定internal Microsoft更新服务位置 If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) { New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null } Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "UseWUServer" -Type DWord -Value 0 #组策略2:启动配置自动更新 Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoUpdate" -Type DWord -Value 0 #组策略3:不删除使用所有 Windows 更新功能的访问权限 Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "SetDisableUXWUAccess" -Type DWord -Value 0 #组策略1:恢复错误配置 If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate")) { New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Force | Out-Null } Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "WUServer" -Type String -Value "" Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "WUStatusServer" -Type String -Value "" #组策略4:允许更新延迟策略对 Windows 更新执行扫描 Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "DisableDualScan" -Type DWord -Value 0 #组策略5:策略名称:指定可选组件安装和组件修复的设置 If (!(Test-Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing")) { New-Item -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing" -Force | Out-Null } Remove-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing" -Name "RepairContentServerSource" Remove-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing" -Name "UseWindowsUpdate" Write-Output "enable windows update successful" } 三,将脚本制作成工具注意:不要在正在下载补丁或者已经安装完补丁等待重启时执行禁用,如果已安装补丁,则更新完系统重启一次后再禁用。 禁用后表现为如下现象,将永远无法找到补丁源: 四,启用自动更新如果你需要重新开启自动更新功能,可以使用该voitools工具解除禁用 解除禁用后重启即可恢复下载补丁 五,工具的下载链接和源代码如下:阿里云盘链接:https://www.aliyundrive.com/s/fTSZMmQc4WM 百度网盘链接:https://pan.baidu.com/s/1QnoYc4BKsLswKhbij_Do8g 。提取码:r8lv |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |